package 面试今典150;

public class 今典3_26删除有序数组的重复项 {
    public int removeDuplicates(int[] nums) {
        /*
        思路：双指针
         */
        int left = 1,right = 1;
        while (right < nums.length){
            if (nums[right-1] != nums[right]){
                nums[left++] = nums[right];
            }
            right++;
        }
        return left;
    }

    public static void main(String[] args) {
        new 今典3_26删除有序数组的重复项().removeDuplicates(new int[]{1,1,2});
    }
}
